#include "../include/codeAnalyze.hpp"



bool soulc::isDigit(char symbol)
{
	std::vector<char> digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

	if (soulc::inList<char>(digits, symbol)) {
		return true;
	}

	return false;
}

bool soulc::isLetter(char symbol)
{
	std::vector<char> letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
								'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

	if (soulc::inList<char>(letters, symbol)) {
		return true;
	}

	return false;
}


bool soulc::checkForNameEnds(char symbol)
{
	if (symbol == '\n' || symbol == '\t' || symbol == ' ') return true;
	return false;
}


std::string soulc::getCodeLine(std::string code, uint64_t line)
{
	std::string codeLine;
	uint64_t curLine = 1;

	for (uint64_t i = 0; i < code.size(); i++) {
		if (code[i] == '\n') curLine++;

		if (curLine == line) {
			for (uint64_t j = i+1; j < code.size(); j++) {
				if (code[j] == '\n') return codeLine;

				codeLine += code[j];
			}
		}
	}

	return codeLine;
}
